package com.anrongtec.zcpt.util;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.anrongtec.zcpt.R;
import com.anrongtec.zcpt.manager.AppDownManagerActivity;

/**
 * 底部提示框工具类
 * @author cxy
 *
 */
public class SnackbarUtil {
	
	/**
	 * 显示已经添加到下载列表,  点击按钮跳转到下载页面
	 * @param activity
	 * @param button
	 */
	public static void showSnackbar(final Activity activity, final View button) {
		Snackbar snackbar = Snackbar.make(button, "已添加到下载列表", 3000);
		View snackbarView = snackbar.getView();
		if(snackbarView!=null){
	        ((TextView) snackbarView.findViewById(R.id.snackbar_text)).setTextColor(Color.WHITE);//获取Snackbar的message控件，修改字体颜色
	    }
		snackbar.setAction("查看", new OnClickListener() {
			@Override
			public void onClick(View v) {
				activity.startActivity(new Intent(activity, AppDownManagerActivity.class));
			}
		}).show();
	}
	
}
